package com.lujianfei.powerinput.ui.setting;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.lujianfei.powerinput.R;
import com.lujianfei.powerinput.base.BaseActivity;
import com.lujianfei.powerinput.ui.setting.base.SettingContract;
import com.lujianfei.powerinput.ui.setting.presenter.SettingPresenter;

import java.util.ArrayList;
import java.util.List;

public class SettingActivity extends BaseActivity implements SettingContract.View {

    private SettingContract.Presenter presenter;

    private ListView listview;
    private ArrayAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
        initData();
        initEvent();
        setTitleMiddleText("设置");
        showTitleLeftImage();
        presenter = new SettingPresenter(this);
    }

    private void initEvent() {
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                presenter.onItemClick(adapterView,view,i,l);
            }
        });
    }

    private void initData() {
        final List<String> a=new ArrayList<>();
        a.add(getString(R.string.template_settings));
        a.add(getString(R.string.about));
        adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,a);
        listview.setAdapter(adapter);
    }

    private void initView() {
        listview = findViewById(R.id.listview);
    }

    @Override
    protected int getTitleBarResId() {
        return R.id.custom_titlebar;
    }

    @Override
    public Activity currentActivity() {
        return this;
    }
}
